package com.cpkso.buss.backend.config;

import org.springframework.context.annotation.Configuration;

/**
 * @author wrzhxy@qq.com
 * @date 2018年1月8日
 */
@Configuration
public class HibernateConfig {
	/**
	 * 建立视图内拦截器来解决JPA中访问延迟加载属性时产生的无会话异常
	 * LazyInitializationException: could not initialize proxy no session
	 * 此拦截器会注入到servlet配置中的DefaultAnnotationHandlerMapping中
	 * 
	 * @param entityManagerFactory
	 * @return
	 */
//	@Bean
//    public OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor(EntityManagerFactory entityManagerFactory) {
//    	OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor = new OpenEntityManagerInViewInterceptor();
//    	openEntityManagerInViewInterceptor.setEntityManagerFactory(entityManagerFactory);
//    	return openEntityManagerInViewInterceptor;
//    }
//	
//	@Bean
//	public RequestMappingHandlerMapping requestMappingHandlerMapping(OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor) {
//		RequestMappingHandlerMapping mapping = new RequestMappingHandlerMapping();
//		mapping.setInterceptors(openEntityManagerInViewInterceptor);
//		return mapping;
//	}
}
